'use strict';

var debug = require('debug'),
  log = debug('yozh:mo:log'),
  error = debug('yozh:mo:error'),
  verbose = debug('yozh:mo:verbose');

module.exports = exports = function modelPlugin (schema, options) {
  // schema.add({updatedAt: Date});
  // check role, user;

  /*schema.pre('save', function (next) {
    this.updatedAt = new Date;
    if (options && options.userId) {
      this.updatedBy = userId;
    }
    log('save entity by time: ', this.updatedAt);
    next();
  });*/

  /*schema.pre('update', function() {
    log('update entity by time: ', this.updatedAt);
    this.update({}, {$set: {updatedAt: new Date()}});
  });*/

  /*schema.post('init', function(doc) {
    log('%s has been initialized from the db', doc._id);
  });
  schema.post('validate', function(doc) {
    log('%s has been validated (but not saved yet)', doc._id);
  });
  schema.post('save', function(doc) {
    log('%s has been saved', doc._id);
  });
  schema.post('remove', function(doc) {
    log('%s has been removed', doc._id);
  });*/

  if (options && options.index) {
    // schema.path('updatedAt').index(options.index);
  }
};
